from flask import Flask, render_template, request, send_from_directory

from source.upload import upload_file, extract_ppt_titles

app = Flask(__name__)
# file_path_root = "H:\\"
file_path_root = "/home/will"


@app.route("/", methods=["GET", "POST"])
def home():
    return render_template("homepage.html")


@app.route("/upload", methods=["GET", "POST"])
def upload():
    if request.method == "POST":
        url = upload_file()
        return render_template('homepage.html', download_url=url)

    return render_template("homepage.html")


@app.route('/download/<filename>', methods=['GET'])
def download(filename):
    directory = file_path_root
    return send_from_directory(directory, filename, as_attachment=True)


if __name__ == "__main__":
    # app.run(port=85)
    app.run()


